from behave import *

from server.app.cloud_ide.service.system_info_service import SystemInfoService
from server.framework.core.logger import logger

system_info_service = SystemInfoService()


@given('用户查看节点列表')
def 用户查看节点列表(context):
    all_nodes = system_info_service.get_all_nodes()
    logger.info(all_nodes)


@given('展示所有节点的全部指标')
def 用户查看节点列表(context):
    metric_name = ['memory_size', 'memory_usage', 'memory_percent_usage',
                   'disk_write', 'disk_read',
                   'network_receive', 'network_transmit',
                   'cpu_cores', 'cpu_percent_usage', 'cpu_usage',
                   'disk_usage', 'disk_size', 'disk_percent_usage',
                   'node_load5']
    metrics = system_info_service.load_node_metric(metrics=metric_name, node_lists=None,
                                                   start=None, end=None, step=None)
    logger.info(metrics)
